<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class mDownload extends CI_Model {
    function getTerritory($user_id){
        $this->db->select('ter.territory_type_name');
        $this->db->select("f_get_region(usr.user_id) as Region");
        $this->db->select("f_get_cluster(usr.user_id) as Cluster");
        $this->db->where("usr.user_id",$user_id);
        $this->db->join("t_mtr_user_group as ugroup","ugroup.user_group_id=usr.user_group_id");
        $this->db->join("t_mtr_territory_type as ter","ter.territory_type_id=ugroup.territory_type_id");
        $pattern=$this->db->get('t_mtr_user as usr')->result_array();
        return $pattern[0];
    }
}